<template>
	<view class="">
		<!-- 头部 -->
		<Tabs></Tabs>
		<!-- 内容 -->
		<view class="content">
			<!-- 卡片 -->
			<view class="card">
				<view class="first-tier">
					<img src="" alt="" v-if="userInfo" class="vip-image">
					<img class="vip-image" src="https://s1.ax1x.com/2022/07/27/vpmxWF.png" alt="" v-else>
					<view class="vip-text" v-if="isVip==false">
						<view class="first-tier-text">
							<view class="denglu">
								<text>欢迎你，新朋友</text>
							</view>
							<view class="huiyuan" @click="turnToMyVIP">
								开通
							</view>
						</view>
						<view class="second-tier-text">
							8元开通VIP，畅学明初独家菜谱
						</view>
					</view>
					<view class="vip-text vip-text-else" v-else>
						<view class="first-tier-text">
							<view class="denglu vip_denglu">
								<view v-if="nickName">尊贵的VIP：<text class="nickName">{{nickName}}</text></view>
								<view class="youxiaoqi">
									<text v-if="nickName">VIP有效期至{{vipdate}}</text>
								</view>
							</view>
							<view class="huiyuan xufei" @tap="turnToMyVIP">
								续费
							</view>
						</view>
					</view>
				</view>

				<view class="second-tier">
					<view class="second-tier-item">
						<image src="https://s1.ax1x.com/2022/07/27/vpKTQe.png" mode="" class="second-tier-image">
						</image>
						<text class="second-tier-text">名厨课程</text>
					</view>
					<view class="second-tier-item">
						<image src="https://s1.ax1x.com/2022/07/27/vpKIzD.png" mode="" class="second-tier-image">
						</image>
						<text class="second-tier-text">无广告打扰</text>
					</view>
					<view class="second-tier-item">
						<image src="https://s1.ax1x.com/2022/07/27/vpK5RO.png" mode="" class="second-tier-image">
						</image>
						<text class="second-tier-text">身份标识</text>
					</view>
				</view>
			</view>

			<!-- VIP最新推荐 -->
			<view class="newest-recommand">
				<text class="newest-recommand-title">VIP最新推荐</text>
				<view class="newest-recommand-container">
					<view class="rec-item" v-for="item in getList" :key="item._id">
						<video :src="item.vid" controls class="rec-image"></video>
						<text>{{item.name}}</text>
						<view class="rec-bottom">
							<view class="rec-bottom-left">
								<text class="rec-subtitle">{{item.pageview}}</text>
								<image src="" mode="" class="rec-bottom-image"></image>
							</view>
							<view class="rec-bottom-right">
								<text class="rec-subtitle">{{item.collections}}</text>
								<image src="" mode="" class="rec-bottom-image"></image>
							</view>
						</view>
					</view>
				</view>
			</view>

			<!-- 限时免费体验 -->
			<view class="newest-recommand">
				<text class="newest-recommand-title">限时免费体验</text>
				<view class="newest-recommand-container">
					<view class="rec-item" v-for="item in freeList" :key="item._id">
						<video :src="item.vid" controls class="rec-image"></video>
						<text>{{item.name}}</text>
						<view class="rec-bottom">
							<view class="rec-bottom-left">
								<text class="rec-subtitle">{{item.pageview}}</text>
								<image src="" mode="" class="rec-bottom-image"></image>
							</view>
							<view class="rec-bottom-right">
								<text class="rec-subtitle">{{item.collections}}</text>
								<image src="" mode="" class="rec-bottom-image"></image>
							</view>
						</view>
					</view>
				</view>
			</view>

			<!-- 猜你喜欢 -->
			<view class="newest-recommand">
				<text class="newest-recommand-title">猜你喜欢</text>
				<view class="newest-recommand-container flex-wrap" >
					<view class="rec-item resize-item"
					v-for="item in likeList"
					:key="item._id">
						<image :src="item.coverpic" class="rec-image resize-image"></image>
						<text>{{item.name}}</text>
						<view class="rec-bottom">
							<view class="rec-bottom-left">
								<text class="rec-subtitle">{{item.pageview}}</text>
								<image src="" mode="" class="rec-bottom-image"></image>
							</view>
							<view class="rec-bottom-right">
								<text class="rec-subtitle">{{item.collections}}</text>
								<image src="" mode="" class="rec-bottom-image"></image>
							</view>
						</view>
					</view>
				</view>
			</view>

		</view>
	</view>
</template>

<script>
	import {
		createNamespacedHelpers
	} from "vuex"
	const {
		mapState,
		mapMutations
	} = createNamespacedHelpers("vipModule")
	export default {
		data() {
			return {
				userInfo: '',
				isVip: false,
				status: true,

			}
		},
		created() {
			this.findData()
		},
		methods: {
			...mapMutations(['vip']),
			async findData() {
				// 	//授权微信登录
				// 	let wxLogin = await this.$api.home.wxLoginData()
				// 	//登录成功后更新数据库信息
				// 	let auth = await this.$api.home.authData()
				//获取用户信息
				// let getUser = await this.$api.vip.getUserInfoData()

				// 最新推荐
				let menuGet = await this.$api.vip.getRecommendMenuListData()
				let menuGetMessage = menuGet.data.menus

				//限时免费
				let menuFree = await this.$api.vip.getisFreeMenuListData()
				let menuFreeMessage = menuFree.data.menus

				//猜你喜欢
				let menuLike = await this.$api.vip.likeMenuData()
				let menuLikeMessage = menuLike.data.menus


				let viprequest = {
					menuGetMessage,
					menuFreeMessage,
					menuLikeMessage
				}

				this.vip(viprequest)
				console.log(viprequest);
				console.log(this.getList);
				console.log(this.freeList);
				console.log(this.likeList);
			},
			//点击开通跳转到我的会员
			turnToMyVIP(){
				uni.navigateTo({
					url:'/pagesB/openVip/openVip'
				})
			}
		
		},
		computed: {
			...mapState(['getList', 'freeList', 'likeList'])
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		padding: 0 32rpx;
		margin-top: 14rpx;

		.card {
			width: 100%;
			height: 324rpx;
			background-image: linear-gradient(to right, #25262e, #43454f, #25262e);
			border-radius: 20rpx;
			position: relative;

			.first-tier {
				display: flex;

				.vip-image {
					width: 108rpx;
					height: 108rpx;
					margin-top: 32rpx;
					margin-left: 32rpx;
					margin-right: 18rpx;
					border-radius: 50%;
					flex-shrink: 0;
				}

				.vip-text {
					margin-top: 32rpx;

					.first-tier-text {
						display: flex;
						align-items: center;

						.denglu {
							color: #aaa;
						}

						.vip_denglu {
							margin-top: 20rpx;
							display: flex;
							flex-direction: column;

							.nickName {
								font-weight: bolder;
								font-size: 35rpx;
							}
						}


						.huiyuan {
							background-image: linear-gradient(to bottom, #e7b799, #f4dac0);
							color: #76401f;
							font-weight: bold;
							width: 106rpx;
							height: 32rpx;
							border-radius: 16rpx;
							text-align: center;
							line-height: 32rpx;
							margin-left: 210rpx;
							margin-top: 3rpx;
						}

						.xufei {
							margin-right: 28rpx;
							margin-left: 85rpx;

							.youxiaoqi {
								margin-top: 80rpx;
							}
						}
					}

					.second-tier-text {
						margin-top: 18rpx;
						color: #fff;
					}
				}

			}

			.second-tier {
				display: flex;
				width: 100%;
				justify-content: space-between;
				padding: 0 32rpx;
				background-image: linear-gradient(to bottom, #050505, #4f4f4f);
				position: absolute;
				bottom: 0;
				left: 0;
				height: 100rpx;
				border-bottom-right-radius: 20rpx;
				border-bottom-left-radius: 20rpx;

				.second-tier-item {
					display: flex;
					flex-direction: column;
					justify-content: center;
					align-items: center;

					.second-tier-image {
						width: 40rpx;
						height: 40rpx;
						border-radius: 50%;
					}

					.second-tier-text {
						color: #fff;
					}

				}
			}

		}

		.newest-recommand {
			margin-top: 44rpx;

			.newest-recommand-title {
				font-size: 40rpx;
				font-weight: bolder;
			}

			//隐藏滚动条
			::-webkit-scrollbar {
				width: 0;
				height: 0;
				background-color: transparent;
			}

			.newest-recommand-container {
				display: flex;
				overflow-x: scroll;
				margin-top: 28rpx;

				.rec-item {
					width: 334rpx;
					height: 345rpx;
					margin-right: 12rpx;

					.rec-image {
						width: 334rpx;
						height: 248rpx;
						border-radius: 10rpx;
					}

					.rec-subtitle {
						font-size: 27rpx;
						color: #aaa;
					}

					.rec-bottom {
						display: flex;

						.rec-bottom-left {
							margin-right: 30rpx;
							display: flex;
							align-items: center;
						}

						.rec-bottom-right {
							display: flex;
							align-items: center;
						}

						.rec-bottom-image {
							width: 28rpx;
							height: 25rpx;
							margin-left: 10rpx;
						}
					}


				}
			}

			.flex-wrap {
				flex-wrap: wrap;

				.resize-item {
					&:nth-child(2n) {
						margin-right: 0;
					}
				}
			}

		}

	}
</style>
